package btanalyzer.db.dao;

import javax.persistence.TypedQuery;

import org.springframework.stereotype.Component;

import btanalyzer.db.model.AnnounceUrl;

@Component
public class AnnounceUrlDaoImpl extends GenericDaoAbstract<AnnounceUrl, Long> implements AnnounceUrlDao {

	private static final String className = AnnounceUrl.class.getName();
	
	@Override
	public AnnounceUrl selectByUrl(String url) {
		TypedQuery<AnnounceUrl> q = getEntityManager().createQuery(
				"select a from " + className + " a where a.url=?", AnnounceUrl.class);
		q.setParameter(1, url);
		return q.getSingleResult();
	}

	@Override
	public long countByUrl(String url) {
		TypedQuery<Long> q = getEntityManager().createQuery(
				"select count(a) from " + className + " a where a.url=?", Long.class);
		q.setParameter(1, url);
		return q.getSingleResult();
	}
}
